<script setup>
import { Search } from '@element-plus/icons-vue';
import ItemContainerCard from './item-container-card.vue';
import { useItemContainerCheckBox } from '@/hooks/work/work-todo/useItemContainerCheckBox';
import TodoContainerApproval from './todo-container-approval.vue';

const {
  checkAll,
  isIndeterminate,
  checkedCities,
  cities,
  handleCheckAllChange,
  handleCheckedCitiesChange } = useItemContainerCheckBox();
const approvalRef = ref(null);

const handleAgree = () => {
  approvalRef.value.show();
};
const handleDisagree = () => {
  approvalRef.value.show();
};
</script>

<template>
  <div class="todo-container">
    <el-input
      size="large"
      placeholder="搜索待办事项标题"
      :suffix-icon="Search"
    />
    <div class="operate">
      <el-checkbox
        class="check__all"
        v-model="checkAll"
        :indeterminate="isIndeterminate"
        @change="handleCheckAllChange"
        >全部选择</el-checkbox
      >
      <div class="operate__button">
        <el-button type="primary">转办</el-button>
        <el-button type="primary" @click="handleAgree">同意</el-button>
        <el-button @click="handleDisagree">不同意</el-button>
      </div>
    </div>
    <label class="total">相关待办共计1项</label>
    <el-checkbox-group
      class="check__group"
      v-model="checkedCities"
      @change="handleCheckedCitiesChange"
    >
      <el-checkbox  v-for="city in cities" :key="city" :label="city">
        <item-container-card class="check__group-card" @click.prevent></item-container-card>
      </el-checkbox>
    </el-checkbox-group>
  </div>
  <todo-container-approval ref="approvalRef"></todo-container-approval>
</template>

<style lang="scss" scoped>
.todo-container {
  padding: 20px 24px;

  .operate {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 23px;

    .check__all {
      font-size: 14px;
      font-weight: 400;
      color: #25292C;
      line-height: 21px;
    }
  }

  .total {
    margin-top: 25px;
    margin-left: 35px;
    font-size: 12px;
    font-weight: 400;
    color: #989DA3;
    line-height: 55px;
  }

  .check__group {
    :deep(.el-checkbox) {
      position: relative;
      height: auto;
      margin-bottom: 17px;

      .check__group-card {
        width: 1283px;
        margin-left: 33px;
      }

      .el-checkbox__input {
        position: absolute;
        top: 30px;
      }

      .el-checkbox__label {
        padding-left: 0;
      }
    }
  }
}
</style>
